@import '../common/index.less';

@item: ~'@{prefix}-tab-bar-item';

@tab-bar-height: var(--td-tab-bar-height, 80rpx);
@tab-bar-color: var(--td-tab-bar-color, @text-color-primary);
@tab-bar-bg-color: var(--td-tab-bar-bg-color, @bg-color-container);
@tab-bar-border-color: var(--td-tab-bar-border-color, @border-color);
@tab-bar-hover-bg-color: var(--td-tab-bar-hover-bg-color, rgba(0, 0, 0, 0.05));
@tab-bar-active-color: var(--td-tab-bar-active-color, @brand-color);
@tab-bar-active-bg: var(--td-tab-bar-active-bg, @brand-color-light);
@tab-bar-spread-shadow: var(--td-tab-bar-spread-shadow, @shadow-3);
@tab-bar-spread-border-color: var(--td-tab-bar-spread-border-color, @border-color);

:host {
  flex: 1;
}

.@{item} {
  flex: 1;
  height: @tab-bar-height;
  box-sizing: border-box;
  user-select: none;
  position: relative;
  margin: 16rpx 0;
  background-color: @tab-bar-bg-color;
  padding: 0 24rpx;

  &--text-only {
    font-size: 32rpx;
  }

  &--split {
    & + &::before {
      .hairline-left(@color: @tab-bar-border-color);
      top: 16rpx;
      bottom: 16rpx;
    }
  }

  &--crowded {
    padding: 0 16rpx;
  }

  &--round {
    border-radius: 99px;
  }

  &__content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 16rpx;
    color: @tab-bar-color;

    &--checked {
      color: @tab-bar-active-color;
      font-weight: 600;
    }

    &--tag {
      border-radius: 99px;
    }

    &--tag&--checked {
      background-color: @tab-bar-active-bg;
    }

    // &--active {
    //   background-color: @tab-bar-hover-bg-color;
    // }
  }

  &__icon:empty {
    display: none;
  }

  &__text {
    display: flex;
    align-items: center;

    &--small {
      font-size: 20rpx;
      line-height: 32rpx;
    }
  }

  &__icon-menu {
    margin-right: 8rpx;
  }

  &__spread {
    position: absolute;
    top: 0;
    left: 7%;
    width: 86%;
    background-color: @tab-bar-bg-color;
    transform: translate3d(0, calc(-100% - 32rpx), 0);
    z-index: 1;
    border-radius: 12rpx;
    color: @tab-bar-color;
    box-shadow: @tab-bar-spread-shadow;

    &::before {
      display: block;
      content: '';
      position: absolute;
      bottom: 0;
      left: 50%;
      width: 0;
      height: 0;
      border: 16rpx solid transparent;
      border-top: 16rpx solid @tab-bar-bg-color;
      transform: translate3d(-50%, 32rpx, 0);
    }

    &-item {
      width: 100%;
      height: 96rpx;
      display: flex;
      align-items: center;
      justify-content: flex-start;
      position: relative;
      flex-direction: column;

      &--active {
        background-color: @tab-bar-hover-bg-color;
      }

      &-split {
        box-sizing: border-box;
        content: ' ';
        pointer-events: none;
        background-color: @tab-bar-spread-border-color;
        width: 80%;
        height: 1px;
        transform: translateY(0.5);
      }

      &-text {
        padding-top: 24rpx;
      }
    }
  }
}
